<template>
  <div class="headlineDetails">
    <!-- 头部 -->
    <div class="nav-bar">
      <van-nav-bar @click-left="$router.push(path)">
        <template #title>
          <div class="title">主客直播</div>
        </template>
        <template #left>
          <i class="iconfont">&#xe660;</i>
        </template>
      </van-nav-bar>
    </div>
    <!-- 内容 -->
    <div class="box">
      <div class="header">
        <h2 class="title">
          {{ infocontent.title }}
        </h2>
        <div class="info">
          <span>{{ infocontent.timeDesc }}</span>
          <span>{{ infocontent.readCount }}人浏览</span>
        </div>
      </div>
      <div class="content">
        <div class="content-box" v-html="infocontent.contentText">
          <!-- <p v-html="infocontent.contentText"> -->
          <!-- {{ infocontent.contentText }} -->
          <!-- </p> -->
        </div>
        <div class="tag">
          <div class="item">
            <span
              ><i class="iconfont">&#xe610;</i>&nbsp;&nbsp;
              {{ infocontent.contentColumn }}</span
            >
          </div>
        </div>
      </div>
    </div>
    <!-- 更多 -->
    <div class="list">
      <div
        class="real-time-info"
        v-for="(item, index) in recommendList"
        :key="index"
      >
        <div class="left">
          <h4 class="title">
            {{ item.title }}
          </h4>
          <div class="info">
            <div class="info-left">
              <i class="iconfont">&#xe610;</i>&nbsp;{{ item.contentColumn }}
            </div>
            <div class="type">{{ item.readCount }}人浏览</div>
          </div>
        </div>
        <div class="right">
          <img class="img" :src="item.image" alt="" />
        </div>
      </div>
    </div>
    <div class="tabbar" :class="{ pb: $route.meta.detailTabbar }">
      <van-tabbar
        class="height"
        v-model="active"
        route
        v-show="$route.meta.detailTabbar"
      >
        <van-tabbar-item>
          <i class="iconfont">&#xe612;</i>
          <div class="text">收藏15</div>
        </van-tabbar-item>
        <van-tabbar-item>
          <i class="iconfont">&#xe60f;</i>
          <div class="text">点赞15</div>
        </van-tabbar-item>
      </van-tabbar>
    </div>
  </div>
</template>

<script>
import { informationDetails, recommendInformation } from '@/api/find.js'
export default {
  data () {
    return {
      active: 0,
      path: '/home/find',
      columnld: this.$route.query.id,
      contentId: this.$route.query.columnld,
      infocontent: {},
      recommendList: []
    }
  },
  async created () {
    // 文章详情
    const res = await informationDetails({
      contentId: this.columnld
    })
    console.log('xaingqing', res)
    this.infocontent = res.data.data
    // 更多
    const res1 = await recommendInformation({
      pageNum: 1,
      pageSize: 3,
      query: {
        contentColumnId: this.contentId.toString(),
        contentId: this.columnld.toString()
      }
    })
    console.log('gengduo', res1)
    this.recommendList = res1.data.data.records
  },
  methods: {}
}
</script>

<style lang="less">
.headlineDetails {
  .box {
    width: 100%;
    background-color: #f7f8fa;
    .header {
      background-color: #fff;
      padding: 8px 16px 13px;
      .title {
        font-size: 20px;
        font-weight: 700;
        line-height: 26px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .info {
        margin-top: 8px;
        font-size: 12px;
        line-height: 16px;
        color: #888;
        display: flex;
        justify-content: space-between;
      }
    }
    .content {
      background-color: #fff;
      padding: 12px 16px 16px;
      margin-top: 8px;
      .content-box {
        p {
          font-size: 18px;
          line-height: 25px;
          color: #464646;
          margin-top: 5px;
          img {
            width: 100%;
            display: block;
            margin: 8px 0;
          }
        }
      }
      .tag {
        margin-top: 10px;
        display: inline-block;
        font-size: 12px;
        .item {
          span {
            padding: 2px 7px;
            font-size: 12px;
            color: #888;
            background-color: #f6f6f6;
            border-radius: 14px;
            display: flex;
            align-items: center;
            .iconfont {
              color: #e09494;
            }
          }
        }
      }
    }
  }
  .list {
    background-color: #fff;
    padding: 0 15px;
    padding-bottom: 60px;
    .real-time-info {
      display: flex;
      padding: 15px 0;
      border-bottom: 1px solid #f7f7f7;
      .left {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding-right: 15px;
        .title {
          font-weight: 600;
          font-size: 15px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2; // 控制多行的行数
          -webkit-box-orient: vertical;
        }
        .info {
          display: flex;
          justify-content: space-between;
          font-size: 14px;
          align-items: center;
          .info-left {
            padding: 2px 7px;
            background-color: #ffefef;
            border-radius: 9px;
            color: #e09494;
            font-size: 14px;
            .iconfont {
              font-weight: 500;
            }
          }
          .type {
            color: #97a8a7;
          }
        }
      }
      .right {
        width: 120px;
        height: 75px;
        .img {
          border-radius: 5px;
          width: 100%;
          height: 100%;
        }
      }
    }
  }
  .tabbar {
    .height {
      position: fixed;
      height: 50px;
      z-index: 999;
      text-align: center;
    }
    &.pb {
      padding-bottom: 50px;
    }
    .van-tabbar-item:nth-child(1) {
      border-right: 1px solid #ccc;
    }
    .van-tabbar-item__icon {
      .iconfont {
        font-size: 16px;
      }
    }
    .van-tabbar-item__text {
      .iconfont {
        font-size: 18px;
      }
      .text {
        margin-top: 3px;
        font-size: 12px;
      }
    }
    // transition切换的效果 淡入 淡出
    // .fade-enter-active,
    .fade-leave-active {
      transition: opacity 0.1s;
    }
    // .fade-enter,
    .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
      opacity: 0;
    }
  }
}
</style>
